package com.shallwead.bna.service;

import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;

import com.shallwead.bna.BnA;
import com.shallwead.bna.object.AdBack;
import com.shallwead.bna.object.AdGcmMsg;
import com.shallwead.bna.util.Logger;

public class PushNotiService extends Service {

	AdGcmMsg gcmMsg = null;
	Context mContext;

	@Override
	public IBinder onBind(Intent intent) {

		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();

		Logger.e("notiservice onCreate");

		Context mContext = PushNotiService.this;
		NotificationManager nm = (NotificationManager) mContext
				.getApplicationContext().getSystemService(
						Context.NOTIFICATION_SERVICE);
		nm.cancel(455444);

		if (BnA.gcmMsg != null) {
			Logger.e(BnA.gcmMsg.toString());
			AdBack ad = AdGcmMsg.parseAdBack(BnA.gcmMsg);
			BnA.goPushAd(mContext, ad);
		} else {
			PushNotiService.this.stopSelf();
		}
		PushNotiService.this.stopSelf();
	}
}
